package com.zbaohuang.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.joanzapata.android.BaseAdapterHelper;
import com.joanzapata.android.QuickAdapter;
import com.zbaohuang.model.CareWarningModel;
import com.zbaohuang.xyh.R;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class CareWarningFragment extends Fragment {

    List<CareWarningModel> careWarningModels;

    QuickAdapter<CareWarningModel> quickAdapter;

    ListView listView;

    View rootView;

    public CareWarningFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_care_warning, container, false);
        return rootView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        listView = (ListView)rootView.findViewById(R.id.careWarningListView);

        careWarningModels = new ArrayList<CareWarningModel>();
        careWarningModels.add(new CareWarningModel(0,"","","","","",""));
        careWarningModels.add(new CareWarningModel(1,"","","","","",""));
        careWarningModels.add(new CareWarningModel(2,"","","","","",""));
        careWarningModels.add(new CareWarningModel(3,"","","","","",""));
        careWarningModels.add(new CareWarningModel(4,"","","","","",""));

        quickAdapter = new QuickAdapter<CareWarningModel>(getActivity(),R.layout.item_care_warning) {
            @Override
            protected void convert(BaseAdapterHelper helper, CareWarningModel item) {

                if (item.getPosition() == 0){
                    helper.setText(R.id.contentTextView,"亲爱的黄先生，刚刚发现您父母最近的社区有中老年人活动在最近举行，赶紧告诉您的父母，让他们一起来加入活动，一起热闹吧；");

                    helper.setText(R.id.datetimeTextView,"2016-04-08 12:39");

                    helper.setVisible(R.id.layout,false);

                } else if(item.getPosition() == 1){

                    helper.setText(R.id.contentTextView,"亲爱的黄先生，下周的气温会特别的寒冷，记得叮嘱父母注意保暖，以免着凉感冒");

                    helper.setText(R.id.datetimeTextView,"2016-04-06 10:50");

                    helper.setVisible(R.id.layout, true);
                    helper.setText(R.id.alertTextView, "给父母挑几件衣服吧！");
                    helper.setImageResource(R.id.imageView1, R.mipmap.yifu1);
                    helper.setImageResource(R.id.imageView2,R.mipmap.yifu2);
                    helper.setImageResource(R.id.imageView3,R.mipmap.yifu3);

                } else if(item.getPosition() == 2){

                    helper.setText(R.id.contentTextView,"亲爱的黄先生，父亲节马上就来到来了，别忘记了向您的爸爸问声好，感谢他的养育之恩！");

                    helper.setText(R.id.datetimeTextView,"2016-04-03 20:39");

                    helper.setVisible(R.id.layout, true);
                    helper.setText(R.id.alertTextView, "给您的父亲挑件礼物吧！");
                    helper.setImageResource(R.id.imageView1, R.mipmap.liwu1);
                    helper.setImageResource(R.id.imageView2,R.mipmap.liwu2);
                    helper.setImageResource(R.id.imageView3,R.mipmap.liwu3);


                } else if(item.getPosition() == 3){
                    helper.setText(R.id.contentTextView,"亲爱的黄先生，系统刚刚监控到您的父亲体温有点高，最近体温在38度左右，请及时留意并去医院检查，以免体温继续升高");

                    helper.setText(R.id.datetimeTextView,"2016-03-30 17:10");

                    helper.setVisible(R.id.layout,false);
                } else if(item.getPosition() == 4){
                    helper.setText(R.id.contentTextView,"亲爱的黄先生，系统刚刚监控到您的母亲血压有点高，请提醒您的母亲按时吃药，如有需要，请及时到医院检查，以免发生意外情况！");

                    helper.setText(R.id.datetimeTextView,"2016-03-17 13:10");

                    helper.setVisible(R.id.layout,false);
                }

            }
        };

        listView.setAdapter(quickAdapter);

        quickAdapter.addAll(careWarningModels);
    }
}
